#!/bin/bash

#!/bin/bash

back_src="/root/code"
back_dest="/root"
back_name="backup_$(date +%Y%m%d_%H%M%S)"
host="root@192.168.88.133"

tar -czvf $back_dest/$back_name $back_src
echo "备份结果"
echo $(ls $back_dest |grep $back_name )

scp $back_dest/$back_name $host:$back_dest
echo "远程备份结果"
echo $(ssh $host "ls $back_dest |grep $back_name")

find $back_dest -type f -name 'backup_*' -exec rm -f {} \;
test -e $back_dest/$back_name && echo "清理失败" || echo "清理成功"




